package lock_thread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/29
 * Time:20:54
 * lock放在try外
 **/
public class Demo3 {
    public static void main(String[] args) {
        Lock lock = new ReentrantLock();
        lock.lock();
        try {
            int num = 1 / 0;
        } finally {
            lock.unlock();
        }
    }
}
